home *** CD-ROM | disk | FTP | other *** search
/ TPUG - Toronto PET Users Group / TPUG Users Group CD / TPUG Users Group CD.iso / AMIGA / AMICUS / AMICUS22.ADF / BasicSorts / InsertionSort.DOC < prev    next >
Text File  |  1987-06-30  |  1KB  |  36 lines

  1. INSERTION SORT DOCUMENTATION
  2.  
  3.    This is a fine-tuned version of Insertionsort as presented in Programming
  4. Pearls by Jon Bentley from AT&T Bell Laboratories.  The file is ready to
  5. merge into your AmigaBasic program via the MERGE command (read the
  6. AmigaBasic manual for details concerning MERGE).  From your program just
  7. call the Insertionsort like this:
  8.  
  9.       call InsertionSort ( m$(),n% )
  10.  
  11. where m$() is the array to be sorted and n% is the upper limit of the array
  12. m$(1..n%).  See what I mean?  The first element in the array must be at the
  13. index 1 and NOT 0 or else the 0 element will not be sorted.
  14.  
  15.    I have tested the code on m$(1..n%) with each field of m$() being 25
  16. characters in length with the following results:
  17.  
  18.    N                 Time to Sort in Seconds
  19. ------------------------------------------------
  20.    10                         1
  21.    20                         2
  22.    50                         5
  23.    100                        17
  24.  
  25.    This algorithm is an O(n^2) algorithm.
  26.  
  27.    Send further questions concerning this code to :
  28.  
  29.    Gregory A. Kendall
  30.    ATN/ Brendallson Software
  31.    522 Neese Road
  32.    Woodstock, GA  30188
  33.  
  34. Auf Wiedersehen!
  35.  
  36.